//
//  ChooseBankVC.m
//  ManageMoney
//
//  Created by 大明 on 16/4/28.
//  Copyright © 2016年 db. All rights reserved.
//

#import "ChooseBankVC.h"
#import "AddCashCard.h"
@interface ChooseBankVC ()<UITableViewDelegate,UITableViewDataSource>
{
//    NSMutableArray *ChooseBankArray;
}
@property (weak, nonatomic) IBOutlet UITableView *ChooseBankTableView;

@end

@implementation ChooseBankVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"选择开户行";
    _ChooseBankTableView.delegate = self;
    _ChooseBankTableView.dataSource = self;
    //footview
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0)];
    _ChooseBankTableView.tableFooterView = footerView;
}

#pragma mark - tableview的代理
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_ChooseBankArray count];
    
}

//修改tableview的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 30;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *indentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if (cell==nil) {
        //        cell = [[NSBundle mainBundle] loadNibNamed:@"PayHistoryCell" owner:self options:nil][0];
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
    }
    NSDictionary *dic = _ChooseBankArray[indexPath.row];
    cell.textLabel.text = CheckNull(dic[@"SUBMC"]);

    
    
    
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSDictionary *dic = _ChooseBankArray[indexPath.row];
    
    AddCashCard *setPrizeVC = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count-2];
    //初始化其属性
    setPrizeVC.choosebankStr = CheckNull(dic[@"SUBMC"]);
    //使用popToViewController返回并传值到上一页面
    [self.navigationController popToViewController:setPrizeVC animated:true];
    
}
@end
